package com.haisen.core.utils;


import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 正则表达式功能类
 */
public class RegexUtil {


    /**
     * 判断字符串是否为数字
      * @param str
     * @return
     */
    public static boolean  isNumber(String str){
           String regRule = "[0-9]*";
          Pattern pattern = Pattern.compile(regRule);
          Matcher match = pattern.matcher(str);
        return match.matches();
      }


      public static List<String> getStrsInMBracket(String str){
          String regule ="(?<=\\[)[^\\]]+";
          Pattern pattern = Pattern.compile(regule);
          Matcher matcher = pattern.matcher(str);
           List<String> retList = new ArrayList<>();
          if (matcher.find()){
            // System.out.println("添加结果"+matcher.group());
              retList.add(matcher.group());
          } else {
              retList.add("");
          }
          return retList;
      }
}
